<template>
<div>
 <el-form :inline="true">
     <el-form-item >
        <el-button
          type="primary"
          @click="flush"
          icon="export"
        >重新汇总</el-button>
      </el-form-item>
    </el-form>
  <BrowseDataList :cate="cate" :cols="cols" :name="name" skipExcelNumber="4" :excelHeader="excelHeader"/>
</div>
</template>
<script>
import { setSaveAfter2019 } from "@/api/案例分析.js";
import { showLoading, hideLoading } from "@/utils/loading"
import BrowseDataList from "@/components/BrowseDataList";
import { getUser } from "@/utils/auth";
import { addYjjyqk, deleteYjjyqk, updateYjjyqk, getYjjyqk, bulkAddYjjyqk } from "@/api/应届毕业生就业情况.js";
import {findComponent} from "@/utils/ui";
import {get开设专业} from  "@/api/开设专业"
import linq from "linq"
export default {
  components: {
    BrowseDataList
  },
  data() {
    return {
      cate: "A7-6-2应届毕业生就业情况表",
      name: "7.6.2 应届毕业生就业情况",
      excelHeader:{B3:"专业所属系部代码",C3:"专业所属系部名称",D3:"专业代码",E3:"专业名称（全称）",F3:"专业方向代码",G3:"专业方向名称（全称）",
      H3:"毕业生数（人）",I3:"毕业生就业情况",I4:"12月31日就业",I5:"就业数(人)",J5:"就业率（%）",K4:"升迁",K5:"升迁数（人）",L5:"升迁率（%）",M4:"转岗",M5:"转岗数（人）",N5:"转岗率（%）",O3:"毕业生用人单位满意情况",
      O4:"满意或基本满意",O5:"人数（人）",P5:"比例（％）",Q4:"一般满意",Q5:"人数（人）",R5:"比例（％）",S4:"不满意",S5:"人数（人）",T5:"比例（％）"},
      cols: [
        //{ label: "专业所属系部代码", prop: "BMBH" },
        { label: "专业所属系部名称", prop: "BMMC" },
        { label: "专业代码", prop: "ZYDM" },
        { label: "专业名称(全称)", prop: "ZYMC" },
        { label: "专业方向代码", prop: "ZYFXDM" },
        { label: "专业方向名称(全称)", prop: "ZYFXMC" },
        { label: "毕业生数(人)", prop: "BYSS" },
        { label: "毕业生就业情况" ,data:[
              {label:"9月1日就业",data:[
                {label:"就业数(人)",prop:"JYQK_0901_JYS"},
                {label:"就业率(%)",prop:"JYQK_0901_JYL"},
                {label:"本地市",data:[
                {label:"就业数(人)",prop:"JYQK_0901_BDS_JYS"},
                {label:"就业率(%)",prop:"JYQK_0901_BDS_BL"}
                ]},
                {label:"本省市",data:[
                {label:"就业数(人)",prop:"JYQK_0901_BSS_JYS"},
                {label:"就业率(%)",prop:"JYQK_0901_BSS_BL"}
                ]},
                {label:"本区域",data:[
                {label:"就业数(人)",prop:"JYQK_0901_BQY_JYS"},
                {label:"就业率(%)",prop:"JYQK_0901_BQY_BL"}
                ]},
                {label:"其他",data:[
                {label:"就业数(人)",prop:"JYQK_0901_QT_JYS"},
                {label:"就业率(%)",prop:"JYQK_0901_QT_BL"}
                ]}
                ]},
                {label:"起薪线(元)",prop:"JYQK_QXX"},
                {label:"对口就业",data:[
                {label:"就业数(人)",prop:"JYQK_DKJY_JYS"},
                {label:"就业率(%)",prop:"JYQK_DKJY_DKL"}
                ]}
        ]},
        { label: "毕业生基于不同生源类型的就业情况" ,data:[
            {label:"普通高中生",data:[
                {label:"毕业生数(人)",prop:"JYQK_PTGZ_BYS"},
                {label:"就业例(人)",prop:"JYQK_PTGZ_JYS"},
                {label:"就业率(%)",prop:"JYQK_PTGZ_JYL"}
                ]},
              {label:"三校生",data:[
                {label:"毕业生数(人)",prop:"JYQK_SXS_BYS"},
                {label:"就业例(人)",prop:"JYQK_SXS_JYS"},
                {label:"就业率(%)",prop:"JYQK_SXS_JYL"}
                ]},
                {label:"五年制高职",data:[
                {label:"毕业生数(人)",prop:"JYQK_WNGZ_BYS"},
                {label:"就业例(人)",prop:"JYQK_WNGZ_JYS"},
                {label:"就业率(%)",prop:"JYQK_WNGZ_JYL"}
                ]},
                {label:"其他",data:[
                {label:"毕业生数(人)",prop:"JYQK_QTBYS"},
                {label:"就业例(人)",prop:"JYQK_QTJYS"},
                {label:"就业率(%)",prop:"JYQK_QTJYL"}
                ]},
        ]},
        { label: "毕业生基于不同招生方式生源的就业情况" ,data:[
              {label:"基于高考的“知识+技能”招生",data:[
                {label:"毕业生数(人)",prop:"JYQK_QGTK_BYS"},
                {label:"就业例(人)",prop:"JYQK_QGTK_JYS"},
                {label:"就业率(%)",prop:"JYQK_QGTK_JYL"}
                ]},
                {label:"对口招生",data:[
                {label:"毕业生数(人)",prop:"JYQK_SSTK_BYS"},
                {label:"就业例(人)",prop:"JYQK_SSTK_JYS"},
                {label:"就业率(%)",prop:"JYQK_SSTK_JYL"}
                ]},
                {label:"单独考试招生",data:[
                {label:"毕业生数(人)",prop:"JYQK_ZZZS_BYS"},
                {label:"就业例(人)",prop:"JYQK_ZZZS_JYS"},
                {label:"就业率(%)",prop:"JYQK_ZZZS_JYL"}
                ]},
                {label:"综合评价招生",data:[
                {label:"毕业生数(人)",prop:"JYQK_ZSRX_BYS"},
                {label:"就业例(人)",prop:"JYQK_ZSRX_JYS"},
                {label:"就业率(%)",prop:"JYQK_ZSRX_JYL"}
                ]},
                {label:"中高职贯通的招生",data:[
                {label:"毕业生数(人)",prop:"JYQK_DDZS_BYS"},
                {label:"就业例(人)",prop:"JYQK_DDZS_JYS"},
                {label:"就业率(%)",prop:"JYQK_DDZS_JYL"}
                ]},
                {label:"技能拔尖人才免试招生",data:[
                {label:"毕业生数(人)",prop:"JYQK_ZZTY_BYS"},
                {label:"就业例(人)",prop:"JYQK_ZZTY_JYS"},
                {label:"就业率(%)",prop:"JYQK_ZZTY_JYL"}
                ]},
                {label:"补充方式",data:[
                {label:"毕业生数(人)",prop:"JYQK_QT_BYS"},
                {label:"就业例(人)",prop:"JYQK_QT_JYS"},
                {label:"就业率(%)",prop:"JYQK_QT_JYL"}
                ]}
        ]},
      ]
    };
  },
   
  methods: {
     async flush() {
    try {
      showLoading();
      var user = getUser();
      await setSaveAfter2019(user.XXID, user.CJPC);
      hideLoading();
    } catch (e) {
      this.$alert(e);
    }
  },
  async  onDlgCreated(model) {
            var dd = findComponent(this,"ZYFXMC");
          var ZYFXMC = linq.from( this.$root.开设专业).distinct("$.ZYFXMC").toArray();
        
          dd.$attrs.items = ZYFXMC.map(item => {
            return { label: item.ZYFXMC, value: item.ZYFXMC};
          });
    },
onChange(model, field, value) {
      //
     if (field == "ZYFXMC") {
        
        var temp =  linq.from( this.$root.开设专业).first(item=>item.ZYFXMC==value);
        model.BMBH = temp.BMBH;
        model.BMMC = temp.BMMC;
        model.ZYMC = temp.ZYMC;
        model.ZYDM = temp.ZYDM;
        
        model.ZYFXDM = temp.ZYFXDM;
        
      }
},
    onadd(model) {
      //
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
          // 
          console.log(JSON.stringify(temp));
          var model = await addYjjyqk(temp);
          console.log(model)
          resolve(model);
      })
      
    },
    onupdate(model) {
      //
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
          // 
          console.log(JSON.stringify(temp));
          var model = await updateYjjyqk(temp);
          console.log(model)
          resolve(model);
      })
      //
    },
    ondelete(model) {
       var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
         await deleteYjjyqk(temp);
          resolve();
      })
    }

  }
};
</script>
<style>
</style>